home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / a86b.arc / ORG.DOC < prev    next >
Encoding:
Text File  |  1986-06-23  |  2.8 KB  |  64 lines

  1. ---ORG.DOC---
  2.  
  3. The ORG Directive
  4.  
  5. Syntax: ORG address
  6.  
  7. ORG moves the output pointer for the segment currently being assembled to
  8. the value of the operand, which should be an absolute constant, or an
  9. expression evaluating to an absolute, non-forward-referenced constant.
  10.  
  11. ORG is most often used in a DATA segment, to control the location of the
  12. data area within the segment.  For example, in programs that fit entirely
  13. into 64K, you provide an ORG directive as the first line within your DATA
  14. segment at the top of your program.  The location given by the ORG is some
  15. location that you are sure will be beyond the end of your program.  If you
  16. are sure that your program will not go beyond 8K (02000 hex), your program
  17. can look like this:
  18.  
  19. DATA SEGMENT
  20. ORG 02000       ; data goes here, beyond the end of the program
  21.  
  22. (your data segment variable and buffer declarations go here)
  23.  
  24. DATA ENDS
  25.  
  26. (your program goes here)
  27.  
  28.  
  29. There is a special side-effect to ORG when it is used in the CODE segment.
  30. If you begin your code segment with ORG 0, then A86 knows that you are not
  31. assembling a .COM program; but are instead assembling a code segment to be
  32. used in some other context (programming a ROM, for example).  The output
  33. file will start at 0, not 0100 as in a .COM file; and the default extension
  34. for the output file will be .OBJ, not .COM.
  35.  
  36. Other than in the above example, you should not in general issue an ORG within
  37. the CODE segment that would lower the value of the output pointer.  This is
  38. because you thereby put yourself in danger of losing part of your assembled
  39. program.  If you re-assemble over space you have already assembled, you will
  40. clobber the previously-assembled code.  Also, be aware that the size of the
  41. output program file is determined by the value of the code segment output
  42. pointer when the program stops.  If you ORG to a lower value at the end of your
  43. program, the output program file will be truncated to the lower-value address.
  44.  
  45. Again, almost no program producing a .COM file will need any ORG directive
  46. in the code segment.  There is an implied ORG 0100 at the start of the program.
  47. You just start coding istructions, and the assembler will put them in the
  48. right place.
  49.  
  50.  
  51. The EVEN Directive
  52.  
  53. Syntax: EVEN
  54.  
  55. The EVEN directive coerces the current output pointer to an even value.  It
  56. does so by adding 1 to the pointer is the pointer was odd; doing nothing if the
  57. pointer was already even.  EVEN is most often used in data segments, before
  58. a sequence of DW directives.  The 16-bit machines of the 86 family fetch words
  59. more quickly when they are aligned onto even addresses; so the EVEN directive
  60. insures that your program will have the faster access to those DW's that follow
  61. it.  (This speed improvement will not be seen on the 8-bit machines, most
  62. notably the 8088 of the original IBM-PC.)
  63.  
  64.